package com.ryskoo.catering.ordermain.domain;

import com.ryskoo.catering.orderaddress.domain.OrderAddressPO;
import com.ryskoo.catering.orderdetail.domain.OrderDetailPO;
import com.ryskoo.catering.orderlog.domain.OrderLogPO;
import com.ryskoo.common.hclconstant.*;
import com.ryskoo.framework.core.bean.BasicPO;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.text.DecimalFormat;
import java.util.List;

/**
 * 订单
 *
 * @author BeHappy
 */
@Entity
@Table(name = "cater_order_main")
public class OrderMainPO extends BasicPO {
    private static final long serialVersionUID = 5849871373243615627L;

    private static final DecimalFormat df = new DecimalFormat("#0.00");

    /**
     * 卖家uuid
     */
    @Column(name = "vendor_uuid", columnDefinition = "char", length = 32)
    private String vendorUuid;

    /**
     * 会员uuid
     */
    @Column(name = "customer_uuid", columnDefinition = "char", length = 32)
    private String customerUuid;

    /**
     * 卖家名称
     */
    @Column(name = "vendor_name", columnDefinition = "varchar", length = 30)
    private String vendorName;

    /**
     * 会员名称
     */
    @Column(name = "customer_name", columnDefinition = "varchar", length = 30)
    private String customerName;

    /**
     * 桌号
     */
    @Column(name = "table_no", columnDefinition = "varchar", length = 30)
    private String tableNo;

    /**
     * 就餐人数
     */
    @Column(name = "person_num", columnDefinition = "int")
    private int personNum;

    /**
     * 总金额=菜品总金额+配送费+餐具费
     */
    @Column(name = "total_price", columnDefinition = "decimal", length = 11, precision = 2)
    private double totalPrice;

    /**
     * 专门给app留的字段，因为double类型，转成json后，会丢掉.00，从而导致app解析失败
     */
    @Transient
    private String totalPriceStr;

    /**
     * 应付金额=总金额-优惠金额
     */
    @Column(name = "pay_price", columnDefinition = "decimal", length = 11, precision = 2)
    private double payPrice;

    /**
     * 专门给app留的字段，因为double类型，转成json后，会丢掉.00，从而导致app解析失败
     */
    @Transient
    private String payPriceStr;

    /**
     * 满减金额
     */
    @Column(name = "mj_price", columnDefinition = "decimal", length = 11, precision = 2)
    private double mjPrice;

    /**
     * 专门给app留的字段，因为double类型，转成json后，会丢掉.00，从而导致app解析失败
     */
    @Transient
    private String mjPriceStr;

    /**
     * 立减金额（新用户立减）
     */
    @Column(name = "lj_price", columnDefinition = "decimal", length = 11, precision = 2)
    private double ljPrice;

    /**
     * 单品优惠券优惠总金额
     */
    @Column(name = "product_coupon_free_price", columnDefinition = "decimal", length = 11, precision = 2)
    private double productCouponFreePrice;

    /**
     * 店铺优惠券优惠总金额
     */
    @Column(name = "vendor_coupon_free_price", columnDefinition = "decimal", length = 11, precision = 2)
    private double vendorCouponFreePrice;

    /**
     * 店铺优惠券明细Uuid
     */
    @Column(name = "coupon_detail_uuid", columnDefinition = "char", length = 32)
    private String couponDetailUuid;

    /**
     * 专门给app留的字段，因为double类型，转成json后，会丢掉.00，从而导致app解析失败
     */
    @Transient
    private String ljPriceStr;

    /**
     * 积分抵扣金额
     */
    @Column(name = "integral_free", columnDefinition = "decimal", length = 11, precision = 2)
    private double integralFree;

    /**
     * 专门给app留的字段，因为double类型，转成json后，会丢掉.00，从而导致app解析失败
     */
    @Transient
    private String integralFreeStr;

    /**
     * 其他优惠
     */
    @Column(name = "other_price", columnDefinition = "decimal", length = 11, precision = 2)
    private double otherPrice;

    /**
     * 专门给app留的字段，因为double类型，转成json后，会丢掉.00，从而导致app解析失败
     */
    @Transient
    private String otherPriceStr;

    /**
     * 优惠金额=满减金额+立减金额+单品优惠券优惠总金额+店铺优惠券优惠金额+积分抵扣金额+其他优惠
     */
    @Column(name = "free_price", columnDefinition = "decimal", length = 11, precision = 2)
    private double freePrice;

    /**
     * 专门给app留的字段，因为double类型，转成json后，会丢掉.00，从而导致app解析失败
     */
    @Transient
    private String freePriceStr;

    /**
     * 菜品总金额=订单明细菜品金额总和
     */
    @Column(name = "product_price", columnDefinition = "decimal", length = 11, precision = 2)
    private double productPrice;

    /**
     * 专门给app留的字段，因为double类型，转成json后，会丢掉.00，从而导致app解析失败
     */
    @Transient
    private String productPriceStr;

    /**
     * 配送费
     */
    @Column(name = "delivery_price", columnDefinition = "decimal", length = 11, precision = 2)
    private double deliveryPrice;

    /**
     * 专门给app留的字段，因为double类型，转成json后，会丢掉.00，从而导致app解析失败
     */
    @Transient
    private String deliveryPriceStr;

    /**
     * 餐具费
     */
    @Column(name = "tableware_price", columnDefinition = "decimal", length = 11, precision = 2)
    private double tablewarePrice;

    /**
     * 专门给app留的字段，因为double类型，转成json后，会丢掉.00，从而导致app解析失败
     */
    @Transient
    private String tablewarePriceStr;

    /**
     * 赠送积分
     */
    @Column(name = "give_integral", columnDefinition = "int")
    private int giveIntegral;

    /**
     * 使用积分
     */
    @Column(name = "use_integral", columnDefinition = "int")
    private int useIntegral;

    /**
     * 订单状态
     */
    @Column(name = "state", columnDefinition = "tinyint", length = 2)
    private int state = OrderStateEnum.SUBMIT.getValue();

    /**
     * 支付状态
     */
    @Column(name = "pay_state", columnDefinition = "tinyint", length = 2)
    private int payState = PayStateEnum.UNPAID.getValue();

    /**
     * 退款状态
     */
    @Column(name = "refund_state", columnDefinition = "tinyint", length = 2)
    private int refundState;

    /**
     * 订单类型
     */
    @Column(name = "order_type", columnDefinition = "tinyint", length = 2)
    private int orderType = OrderTypeEnum.ENTITY.getValue();

    /**
     * 就餐类型
     */
    @Column(name = "eat_type", columnDefinition = "tinyint", length = 2)
    private int eatType = EatTypeEnum.TANGSHI.getValue();

    /**
     * 支付类型
     */
    @Column(name = "pay_type", columnDefinition = "tinyint", length = 2)
    private int payType;

    /**
     * 微信支付渠道
     */
    @Column(name = "wechat_pay", columnDefinition = "tinyint", length = 2)
    private int wechatPay;

    /**
     * 支付时间
     */
    @Column(name = "pay_time", columnDefinition = "char", length = 19)
    private String payTime;

    /**
     * 退款时间
     */
    @Column(name = "refund_time", columnDefinition = "char", length = 19)
    private String refundTime;

    /**
     * 接单时间
     */
    @Column(name = "receive_time", columnDefinition = "char", length = 19)
    private String receiveTime;

    /**
     * 配送时间
     */
    @Column(name = "delivery_time", columnDefinition = "char", length = 19)
    private String deliveryTime;

    /**
     * 完成时间
     */
    @Column(name = "finish_time", columnDefinition = "char", length = 19)
    private String finishTime;

    /**
     * 预约时间
     */
    @Column(name = "reserve_time", columnDefinition = "char", length = 19)
    private String reserveTime;

    /**
     * 备注
     */
    @Column(name = "note", columnDefinition = "varchar", length = 200)
    private String note;

    /**
     * 支付流水号
     */
    @Column(name = "pay_id", columnDefinition = "varchar", length = 32)
    private String payId;

    /**
     * 代客下单、服务员接单时，服务员的uuid
     */
    @Column(name = "waiter_uuid", columnDefinition = "char", length = 32)
    private String waiterUuid;

    /**
     * 服务员的uuid集合
     */
    @Column(name = "waiter_uuids", columnDefinition = "varchar", length = 350)
    private String waiterUuids;

    /**
     * 行业
     */
    @Column(name = "industry", columnDefinition = "varchar", length = 20)
    private String industry;

    /**
     * 退款申请理由
     */
    @Column(name = "refund_note", columnDefinition = "varchar", length = 200)
    private String refundNote;

    /******鲜花行业新增字段begin********/
    /**
     * 配送方式
     */
    @Column(name = "send_type", columnDefinition = "tinyint", length = 2)
    private int sendType;

    /**
     * 配送时间段，如：2018-07-18 08:00 - 09:00
     */
    @Column(name = "send_time", columnDefinition = "varchar", length = 32)
    private String sendTime;
    
    /**
     * 订单是否评价
     */
    @Column(name = "appraise_state")
    private boolean appraiseState = false;

    /**
     * 生日日期，如：2018-07-18
     */
    @Column(name = "birthday", columnDefinition = "char", length = 10)
    private String birthday;

    /******鲜花行业新增字段end********/

    /**
     * 订单状态名称
     */
    @Transient
    private String stateName;
    /**
     * 支付状态名称
     */
    @Transient
    private String payStateName;
    /**
     * 退款状态名称
     */
    @Transient
    private String refundStateName;
    /**
     * 订单类型名称
     */
    @Transient
    private String orderTypeName;
    /**
     * 就餐类型名称
     */
    @Transient
    private String eatTypeName;
    /**
     * 支付类型名称
     */
    @Transient
    private String payTypeName;
    @Transient
    private List<OrderDetailPO> detailList;
    @Transient
    private List<OrderLogPO> logList;
    @Transient
    private OrderAddressPO orderAddress;

    //会员收货地址uuid
    @Transient
    private String addressUuid;

    /**
     * 临时字段，标识下单的平台
     * MP：微信公众号
     * APP：微信小程序
     * OPEN：微信开放平台
     */
    @Transient
    private String wxplat;
    /**
     * 配送方式名称
     */
    @Transient
    private String sendTypeName;


    public String getWaiterUuid() {
        return waiterUuid;
    }

    public void setWaiterUuid(String waiterUuid) {
        this.waiterUuid = waiterUuid;
    }

    public String getVendorUuid() {
        return vendorUuid;
    }

    public void setVendorUuid(String vendorUuid) {
        this.vendorUuid = vendorUuid;
    }

    public String getCustomerUuid() {
        return customerUuid;
    }

    public void setCustomerUuid(String customerUuid) {
        this.customerUuid = customerUuid;
    }

    public String getVendorName() {
        return vendorName;
    }

    public void setVendorName(String vendorName) {
        this.vendorName = vendorName;
    }

    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    public String getTableNo() {
        return tableNo;
    }

    public void setTableNo(String tableNo) {
        this.tableNo = tableNo;
    }

    public int getPersonNum() {
        return personNum;
    }

    public void setPersonNum(int personNum) {
        this.personNum = personNum;
    }

    public double getTotalPrice() {
        return totalPrice;
    }

    public void setTotalPrice(double totalPrice) {
        this.totalPrice = totalPrice;
    }

    public double getPayPrice() {
        return payPrice;
    }

    public void setPayPrice(double payPrice) {
        this.payPrice = payPrice;
    }

    public double getMjPrice() {
        return mjPrice;
    }

    public void setMjPrice(double mjPrice) {
        this.mjPrice = mjPrice;
    }

    public double getLjPrice() {
        return ljPrice;
    }

    public void setLjPrice(double ljPrice) {
        this.ljPrice = ljPrice;
    }

    public double getIntegralFree() {
        return integralFree;
    }

    public void setIntegralFree(double integralFree) {
        this.integralFree = integralFree;
    }

    public double getOtherPrice() {
        return otherPrice;
    }

    public void setOtherPrice(double otherPrice) {
        this.otherPrice = otherPrice;
    }

    public double getFreePrice() {
        return freePrice;
    }

    public void setFreePrice(double freePrice) {
        this.freePrice = freePrice;
    }

    public double getProductPrice() {
        return productPrice;
    }

    public void setProductPrice(double productPrice) {
        this.productPrice = productPrice;
    }

    public double getDeliveryPrice() {
        return deliveryPrice;
    }

    public void setDeliveryPrice(double deliveryPrice) {
        this.deliveryPrice = deliveryPrice;
    }

    public double getTablewarePrice() {
        return tablewarePrice;
    }

    public void setTablewarePrice(double tablewarePrice) {
        this.tablewarePrice = tablewarePrice;
    }

    public int getGiveIntegral() {
        return giveIntegral;
    }

    public void setGiveIntegral(int giveIntegral) {
        this.giveIntegral = giveIntegral;
    }

    public int getUseIntegral() {
        return useIntegral;
    }

    public void setUseIntegral(int useIntegral) {
        this.useIntegral = useIntegral;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public int getPayState() {
        return payState;
    }

    public void setPayState(int payState) {
        this.payState = payState;
    }

    public int getOrderType() {
        return orderType;
    }

    public void setOrderType(int orderType) {
        this.orderType = orderType;
    }

    public int getEatType() {
        return eatType;
    }

    public void setEatType(int eatType) {
        this.eatType = eatType;
    }

    public int getPayType() {
        return payType;
    }

    public void setPayType(int payType) {
        this.payType = payType;
    }

    public int getWechatPay() {
        return wechatPay;
    }

    public void setWechatPay(int wechatPay) {
        this.wechatPay = wechatPay;
    }

    public String getPayTime() {
        return payTime;
    }

    public void setPayTime(String payTime) {
        this.payTime = payTime;
    }

    public String getReceiveTime() {
        return receiveTime;
    }

    public void setReceiveTime(String receiveTime) {
        this.receiveTime = receiveTime;
    }

    public String getDeliveryTime() {
        return deliveryTime;
    }

    public void setDeliveryTime(String deliveryTime) {
        this.deliveryTime = deliveryTime;
    }

    public String getFinishTime() {
        return finishTime;
    }

    public void setFinishTime(String finishTime) {
        this.finishTime = finishTime;
    }

    public String getReserveTime() {
        return reserveTime;
    }

    public void setReserveTime(String reserveTime) {
        this.reserveTime = reserveTime;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public String getStateName() {
        return OrderStateEnum.getNameByValue(this.state);
    }

    public void setStateName(String stateName) {
        this.stateName = stateName;
    }

    public String getPayStateName() {
        return PayStateEnum.getNameByValue(this.payState);
    }

    public void setPayStateName(String payStateName) {
        this.payStateName = payStateName;
    }

    public String getOrderTypeName() {
        return OrderTypeEnum.getNameByValue(this.orderType);
    }

    public void setOrderTypeName(String orderTypeName) {
        this.orderTypeName = orderTypeName;
    }

    public String getEatTypeName() {
        return EatTypeEnum.getNameByValue(this.eatType);
    }

    public void setEatTypeName(String eatTypeName) {
        this.eatTypeName = eatTypeName;
    }

    public String getPayTypeName() {
        return PayTypeEnum.getNameByValue(this.payType);
    }

    public void setPayTypeName(String payTypeName) {
        this.payTypeName = payTypeName;
    }

    public List<OrderDetailPO> getDetailList() {
        return detailList;
    }

    public void setDetailList(List<OrderDetailPO> detailList) {
        this.detailList = detailList;
    }

    public List<OrderLogPO> getLogList() {
        return logList;
    }

    public void setLogList(List<OrderLogPO> logList) {
        this.logList = logList;
    }

    public OrderAddressPO getOrderAddress() {
        return orderAddress;
    }

    public void setOrderAddress(OrderAddressPO orderAddress) {
        this.orderAddress = orderAddress;
    }

    public String getAddressUuid() {
        return addressUuid;
    }

    public void setAddressUuid(String addressUuid) {
        this.addressUuid = addressUuid;
    }

    public String getPayId() {
        return payId;
    }

    public void setPayId(String payId) {
        this.payId = payId;
    }

    public String getWxplat() {
        return wxplat;
    }

    public void setWxplat(String wxplat) {
        this.wxplat = wxplat;
    }

    public int getSendType() {
        return sendType;
    }

    public void setSendType(int sendType) {
        this.sendType = sendType;
    }

    public String getSendTime() {
        return sendTime;
    }

    public boolean isAppraiseState() {
		return appraiseState;
	}

	public void setAppraiseState(boolean appraiseState) {
		this.appraiseState = appraiseState;
	}

	public void setSendTime(String sendTime) {
        this.sendTime = sendTime;
    }

    public String getSendTypeName() {
        return SendTypeEnum.getNameByValue(this.sendType);
    }

    public void setSendTypeName(String sendTypeName) {
        this.sendTypeName = sendTypeName;
    }

    public String getWaiterUuids() {
        return waiterUuids;
    }

    public void setWaiterUuids(String waiterUuids) {
        this.waiterUuids = waiterUuids;
    }

    public String getIndustry() {
        return industry;
    }

    public void setIndustry(String industry) {
        this.industry = industry;
    }

    public String getTotalPriceStr() {
        return df.format(totalPrice);
    }

    public String getPayPriceStr() {
        return df.format(payPrice);
    }

    public String getMjPriceStr() {
        return df.format(mjPrice);
    }

    public String getLjPriceStr() {
        return df.format(ljPrice);
    }

    public String getIntegralFreeStr() {
        return df.format(integralFree);
    }

    public String getOtherPriceStr() {
        return df.format(otherPrice);
    }

    public String getFreePriceStr() {
        return df.format(freePrice);
    }

    public String getProductPriceStr() {
        return df.format(productPrice);
    }

    public String getDeliveryPriceStr() {
        return df.format(deliveryPrice);
    }

    public String getTablewarePriceStr() {
        return df.format(tablewarePrice);
    }


    public double getProductCouponFreePrice() {
        return productCouponFreePrice;
    }

    public void setProductCouponFreePrice(double productCouponFreePrice) {
        this.productCouponFreePrice = productCouponFreePrice;
    }

    public double getVendorCouponFreePrice() {
        return vendorCouponFreePrice;
    }

    public void setVendorCouponFreePrice(double vendorCouponFreePrice) {
        this.vendorCouponFreePrice = vendorCouponFreePrice;
    }

    public String getCouponDetailUuid() {
        return couponDetailUuid;
    }

    public void setCouponDetailUuid(String couponDetailUuid) {
        this.couponDetailUuid = couponDetailUuid;
    }

    public int getRefundState() {
        return refundState;
    }

    public void setRefundState(int refundState) {
        this.refundState = refundState;
    }

    public String getRefundNote() {
        return refundNote;
    }

    public void setRefundNote(String refundNote) {
        this.refundNote = refundNote;
    }

    public String getRefundTime() {
        return refundTime;
    }

    public void setRefundTime(String refundTime) {
        this.refundTime = refundTime;
    }

    public String getRefundStateName() {
        return RefundStateEnum.getNameByValue(this.refundState);
    }

    public void setRefundStateName(String refundStateName) {
        this.refundStateName = refundStateName;
    }

    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }
}
